/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package integration.BuscaPe;

import br.ita.model.dao.DAO;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.map.MappingJsonFactory;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.node.ArrayNode;

/**
 *
 * @author Abraao
 */
public class Buscape  {
    ConnectUrlJson connectURL;
    
    public Buscape(ConnectUrlJson ConnectJsonURL) {
        this.connectURL = ConnectJsonURL;
    }
     
    public List<ProductEntityJson> retrieveProductByKeyword(String keyword) throws IOException {
        String url = BuscapeUrlJson.SEARCH_PRODUCT_BY_KEYWORD.url()+keyword;
        return connectURL.parserJsonToProduct(connectURL.getJsonFrom(url));
    }
    
     public List<ProductEntityJson> retrieveProductByCategory(BuscapeCategorias c) throws IOException {
        String url = BuscapeUrlJson.SEARCH_PRODUCT_BY_CATEGORY_ID.url()+c.id();
        return connectURL.parserJsonToProduct(connectURL.getJsonFrom(url));
    }
}
